<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2018/12/25
 * Time: 16:05
 */
namespace common\logics\valueservice;

use common\models\craftsman\TaskCommod;
use Yii;
use common\widgets\Tool;
use yii\base\BaseObject;
use yii\db\Exception;

class ValueServiceLogic extends BaseObject implements IValueService
{
    /** @var \common\sources\read\buyuser\BuyUserAccess $RBuyUserAccess **/
    private $RBuyUserAccess;
    /** @var \common\sources\write\valueservice\ValueServiceAccess $WValueServiceAccess **/
    private $WValueServiceAccess;
    /** @var \common\sources\read\valueservice\ValueServiceAccess $RValueServiceAccess **/
    private $RValueServiceAccess;
    /** @var \common\sources\write\taskcommod\TaskCommodAccess $WTaskCommodAccess **/
    private $WTaskCommodAccess;
    /** @var \common\sources\read\taskcommod\TaskCommodAccess $RTaskCommodAccess **/
    private $RTaskCommodAccess;
    /** @var \common\sources\write\servicecharge\ServiceChargeAccess $WServiceChargeAccess ***/
    private $WServiceChargeAccess;
    /** @var \common\sources\read\valueserviceprohibit\ValueServiceProhibitAccess $RValueServiceProhibitAccess ***/
    private $RValueServiceProhibitAccess;
    /** @var \common\sources\write\valueserviceprohibit\ValueServiceProhibitAccess $WValueServiceProhibitAccess **/
    private $WValueServiceProhibitAccess;
    /** @var \common\sources\read\buyuser\BuyUserAcountAccess $RBuyUserAcountAccess ***/
    private $RBuyUserAcountAccess;
    /*** @var \common\sources\read\praisekeywords\PraiseKeywordsAccess $RPraiseKeywordsAccess ***/
    private $RPraiseKeywordsAccess;
    /*** @var \common\sources\write\praisekeywords\PraiseKeywordsAccess $WPraiseKeywordsAccess **/
    private $WPraiseKeywordsAccess;
    /**
     * 增值服务类别配置
    */
    private $valueservice;

    public function init()
    {
        $this->valueservice =  require dirname(dirname(dirname(dirname(__FILE__)))).'/config/value-service-config.php';
        $this->RBuyUserAccess = Yii::$container->get("RBuyUserAccess");
        $this->WValueServiceAccess = Yii::$container->get("WValueServiceAccess");
        $this->RValueServiceAccess = Yii::$container->get("RValueServiceAccess");
        $this->WTaskCommodAccess = Yii::$container->get("WTaskCommodAccess");
        $this->RTaskCommodAccess = Yii::$container->get("RTaskCommodAccess");
        $this->WServiceChargeAccess = Yii::$container->get("WServiceChargeAccess");
        $this->RValueServiceProhibitAccess = Yii::$container->get("RValueServiceProhibitAccess");
        $this->WValueServiceProhibitAccess = Yii::$container->get("WValueServiceProhibitAccess");
        $this->RBuyUserAcountAccess = Yii::$container->get("RBuyUserAcountAccess");
        $this->WPraiseKeywordsAccess = Yii::$container->get("WPraiseKeywordsAccess");
        $this->RPraiseKeywordsAccess = Yii::$container->get("RPraiseKeywordsAccess");
        parent::init(); // TODO: Change the autogenerated stub
    }

    public function addValueService($data)
    {
        if(empty($data['return_type'])){
            return Tool::returnJson([],401,"返款方式不能为空");
        }
//        if(empty($data['weight'])){
//            return Tool::returnJson([],402,"请选择快递类型以及设置重量");
//        }
        if(empty($data['bus_id'])){
            return Tool::returnJson([],403,"商户id不能为空");
        }
        if(empty($data['task_commod_id'])){
            return Tool::returnJson([],405,"发布任务id不能为空");
        }
        if(empty($data['free_shipping']))
        {
            return Tool::returnJson([],406,"必须选择包邮或者不包邮");
        }
        if(!($data['free_shipping'] == 1 || $data['free_shipping'] == 2))
        {
            return Tool::returnJson([],407,"任务必须选择包邮或者不包邮");
        }
        $prohibitArr = [];
        $is_prohibit = 0;
        if(!empty($data['prohibit']))
        {
            $data['prohibit'] = array_filter($data['prohibit']);
            if(count($data['prohibit'])>3)
            {
                return Tool::returnJson([],408,"禁止地址步能超过三个");
            }
            $prohibit_pro_arr = array_column($data['prohibit'],"pro_code");
            $prohibit_pro_arr = array_filter($prohibit_pro_arr);
            $prohibit_city_arr = array_column($data['prohibit'],"city_code");
            $prohibit_city_arr = array_filter($prohibit_city_arr);
            if(!(empty($prohibit_pro_arr) || empty($prohibit_city_arr)))
            {
                $prohibitArr = $data['prohibit'];
                $is_prohibit = 1;
            }
        }
        //用户
        $buyUser = $this->RBuyUserAccess->getBuyUserInfo($data['bus_id']);
        if(empty($buyUser)){
            return Tool::returnJson([],409,'商家用户不存在');
        }
        $buyUserAcount = $this->RBuyUserAcountAccess->getBuyUserAccount($data['bus_id']);
//        if(empty($buyUserAcount))
//        {
//            return Tool::returnJson([],410,'没有账号信息，请充值');
//        }
        $task_commod = $this->RTaskCommodAccess->getTaskCommodById($data['task_commod_id']);
        if(empty($task_commod)){
            return Tool::returnJson([],411,"任务订单id不存在");
        }
        //判断是否是图文任务
        if($task_commod['task_type'] == 2 && $task_commod['task_type'] == 0)
        {
            return Tool::returnJson([],413,"图文任务必须先上传图文");
        }
        if($task_commod['bus_id'] != $data['bus_id'])
        {
            return Tool::returnJson([],3000,"非本人任务不得添加增值服务");
        }

//        if($task_commod['public_task_status'] != 3)
//        {
//            return Tool::returnJson([],412,"不能添加增值服务");
//        }
        if(!empty($data['custom_praise']) && $data['praise'] == 3)
        {
            $data['custom_praise'] = array_filter( $data['custom_praise']);
            if(count($data['custom_praise'])>10)
            {
                return Tool::returnJson([],413,"自定义好评关键字总数量不能超过10个");
            }
            if($task_commod['task_num'] != count($data['custom_praise']))
            {
                return Tool::returnJson([],415,"自定义好评关键字总数量与任务数量不匹配");
            }
        }


        //开始时间和结束时间
        if(!empty($data['pub_timing']) && !empty($data['end_timing']))
        {
            if(strtotime($data['end_timing']) - strtotime($data['pub_timing'])<7200)
            {
                return Tool::returnJson([],450,"任务开始时间与结束时间必须大于2小时");
            }
        }

        $praise_arr = [];
        //好评优化部分
        if(!(($task_commod['plat_type'] == 1 || $task_commod['plat_type'] == 2 ) && $task_commod['task_type'] == 2))
        {
            if($data['praise'] == 1)
            {
                $data['praise_keys'] = [];
                $data['custom_praise'] = [];

            }elseif($data['praise'] == 2)
            {
                $data['praise_keys'] = array_filter($data['praise_keys']);
                if(!empty($data['praise_keys']) && $data['praise'] == 2)
                {
                    $data['praise_keys'] = implode( $data['praise_keys'],'|');
                }else
                {
                    unset($data['praise_keys']);
                }
            }else if($data['praise'] == 3)
            {
                //判断是否是自定义好评
                if( $data['praise'] == 3 && $task_commod['task_num']>10)
                {
                    return Tool::returnJson([],416,"自定义好评不得大于10单");
                }
                if($data['praise'] == 3 && count($data['custom_praise'])>0)
                {
                    $data['custom_praise'] = array_filter($data['custom_praise']);
                    if($task_commod['task_num'] != count($data['custom_praise']))
                    {
                        return Tool::returnJson([],417,"自定义关键字数量和任务单数不匹配");
                    }
                    $praise_arr = $data['custom_praise'];
                }else
                {
                    unset($data['praise_keys']);
                }
            }
        }
        $freight_deposit = 0;
        //是否包邮  包邮增加10元押金
        if($data['free_shipping'] == 2)
        {
            $freight_deposit = 10;
        }
        //判断增值服务是否以及添加
        $valueArr = $this->RValueServiceAccess->getValueServiceByCommodId($data['task_commod_id']);
        if(!empty($valueArr)){
            return Tool::returnJson([],418,"任务增值服务已经添加");
        }
        //判断开始实际是否是日期格式
        if(!empty($data['pub_timing']))
        {
            if(strtotime($data['pub_timing']))
            {
                $data['pub_timing'] = strtotime($data['pub_timing']);
            }
        }

        if(!empty($data['end_timing']))
        {
            if(strtotime($data['end_timing']))
            {
                $data['end_timing'] = strtotime($data['end_timing']);
            }
        }
        $avail_task_nu = 0;
        $surplus_task_num = 0;
        if(empty($data['interval_time']) && empty($data['pub_timing']))
        {
            $avail_task_nu = $task_commod['task_num'];
            $surplus_task_num = $task_commod['task_num'];
        }else
        {
            $avail_task_nu = 0;
            $surplus_task_num = 0;
        }
        $task_classify = 1;

        $data['return_type_pepper'] = $data['return_type'] >0 ? number_format($this->valueservice['return_type_pepper'][$data['return_type']] * $task_commod['price']* $task_commod['num'],2,'.','') : 0.00 ;
        //发布间隔
        $data['interval_pepper'] = $data['interval_time'] > 0 ? number_format($this->valueservice['interval_pepper'],2,'.','') : 0.00;
        //定时发布任务
        $data['pub_timing_pepper'] = $data['pub_timing'] > 0 ? number_format($this->valueservice['pub_timing_pepper'],2,'.','') : 0.00;
        //定时结束任务
        $data['end_timing_pepper']  = $data['end_timing'] >0 ? number_format($this->valueservice['end_timing_pepper'],2,'.','') : 0.00;
        //聊天服务类型
        $data['chat_pepper'] = $data['chat_type']> 1 ? number_format($this->valueservice['chat_type_pepper'][$data['chat_type']],2,'.','') : 0.00;
        //延长买手购物周期
        $data['extend_pepper'] = $data['exten_period'] >1 ? number_format($this->valueservice['exten_period_pepper'][$data['exten_period']],2,'.','')  : 0.00;
        //使用花呗信用卡花椒
        $data['credit_card_pepper'] = $data['credit_card'] >0 ? number_format($this->valueservice['credit_card'][$data['credit_card']],2,'.','') : 0.00;
        //买号性别
        $data['sex_pepper'] = $data['buy_sex'] > 1 ? number_format($this->valueservice['buy_sex_pepper'][$data['buy_sex']],2,'.','') : 0.00 ;
        //好评优化
        $data['praise_pepper'] = $data['praise'] > 0  ? number_format($this->valueservice['praise_pepper'][$data['praise']],2,'.','') : 0.00;
        //年龄区间
        $data['buy_age_pepper'] = !empty($data['buy_age'])? number_format($this->valueservice['buy_age_pepper'],2,'.','') : 0.00;
        //任务提升排名
        $data['up_rank_pepper'] = $data['up_rank'] >0 ? number_format($this->valueservice['up_rank_pepper'][$data['up_rank']],2,'.','') : 0.00;
        //禁止地
        $data['prohibit_pepper'] = $is_prohibit == 1 ? number_format($this->valueservice['prohibit_pepper']* count($data['prohibit']),2,'.','') : 0.00 ;
        //佣金加赏
        $data['reword_commise'] = $data['reword_commise']>0 ? number_format($data['reword_commise'],2,'.','') : 0.00;
        //优先审核
        $data['prio_audit_pepper'] = $data['prio_audit']>0 ? number_format($this->valueservice['prio_audit_pepper'][$data['prio_audit']],2,'.','') : 0.00;
        //快递服务花椒
        $data['service_pepper'] = $data['expre_service'] >0 ? number_format($this->valueservice['service_pepper'][$data['expre_service']],2,'.','') : 0.00;
        $value_service_amount = 0.00;
        if($task_commod['task_type'] == 2)
        {
            $value_service_amount = number_format($data['return_type_pepper'] * $task_commod['task_num'] + $data['interval_pepper'] +  $data['pub_timing_pepper'] + $data['end_timing_pepper']
                + $data['chat_pepper']* $task_commod['task_num'] +  $data['extend_pepper'] * $task_commod['task_num']+ $data['credit_card_pepper']* $task_commod['task_num'] + $data['sex_pepper']* $task_commod['task_num'] + $data['buy_age_pepper']+
                $data['praise_pepper'] * $task_commod['task_num'] + $data['up_rank_pepper'] + $data['prohibit_pepper']  + $data['reword_commise']* $task_commod['task_num'] + $data['prio_audit_pepper']
                +  $data['service_pepper'] * $task_commod['task_num'] + $task_commod['img_prase_type_pepper'] * $task_commod['task_num'] + $task_commod['task_img_pepper'] * $task_commod['task_num'],2,'.','');
        }else
        {
            $value_service_amount = number_format($data['return_type_pepper'] * $task_commod['task_num'] + $data['interval_pepper'] +  $data['pub_timing_pepper'] + $data['end_timing_pepper']
                + $data['chat_pepper'] * $task_commod['task_num'] +  $data['extend_pepper'] * $task_commod['task_num']+ $data['credit_card_pepper']* $task_commod['task_num'] + $data['sex_pepper']* $task_commod['task_num'] + $data['buy_age_pepper'] +
                $data['praise_pepper'] * $task_commod['task_num'] + $data['up_rank_pepper'] + $data['prohibit_pepper'] + $data['reword_commise']* $task_commod['task_num'] + $data['prio_audit_pepper']
                +  $data['service_pepper'] * $task_commod['task_num'],2,'.','');
        }
        $pay_task_commisse = number_format( $value_service_amount + $task_commod['com_task_commisse'],2,".","");            //支付任务佣金
        //支付任务佣金
        $pay_task_amount = number_format($task_commod['price']*$task_commod['num']* $task_commod['task_num']*1.05 + $freight_deposit * $task_commod['task_num'],2,".","");   //支付任务总金额
        //总计金额
        $total = number_format($pay_task_commisse + $pay_task_amount,2,".","");
        $item_task_amount = number_format($task_commod['price']* $task_commod['num']*(1+0.05) + $freight_deposit,2,".",""); //每单任务金额（包含任务保证金额）
        $transaction = Yii::$app->db->beginTransaction();
        try{
            $data['task_id'] = $task_commod['task_id'];
            $res = $this->WValueServiceAccess->addValueService($data);
            $value_service_id = Yii::$app->db->getLastInsertID();
            if($res){
                if($data['reword_commise'] > 0)
                {
                    $task_classify = 3;
                }
                if($data['credit_card'] ==1)
                {
                    $task_classify = 2;
                }
                $arr = [
                    'return_type' => $data['return_type'],
                    'freight_deposit' => $freight_deposit,
                    'avail_task_num' => $avail_task_nu,
                    'pay_task_commisse' => $pay_task_commisse,
                    'pay_task_amount' => $pay_task_amount,
                    'total_amount' => $total,
                    'service_amount' => $value_service_amount,
                    "public_task_status" =>4,
                    "task_classify" => $task_classify,
                    "item_task_amount" => $item_task_amount,
                    "surplus_task_num" => $surplus_task_num,
                    'id' => $task_commod['id'],
                ];
                $res_commod = $this->WTaskCommodAccess->modifyTaskCommod($arr);
                if(!$res_commod)
                {
                    $transaction->rollBack();
                    return Tool::returnJson([],420,"修改主任务失败");
                }
                //自定义好评 非图文评论
                if(count($praise_arr) >0)
                {
                    $praise_list = [];
                    foreach ($praise_arr as $para)
                    {
                        $pra_arr = [];
                        $pra_arr['bus_id'] = $task_commod['bus_id'];
                        $pra_arr['task_commod_id'] = $data['task_commod_id'];
                        $pra_arr['value_service_id'] = $value_service_id;
                        $pra_arr['word'] = $para;
                        $pra_arr['create_time'] = time();
                        $praise_list[] = $pra_arr;
                    }
                    $this->WPraiseKeywordsAccess->delPraisekeywords($value_service_id);
                    $res_praise_add = $this->WPraiseKeywordsAccess->addPraiseKeywords($praise_list);
                    if(!$res_praise_add)
                    {
                        $transaction->rollBack();
                        return Tool::returnJson([],421,"添加自定义好评失败");
                    }
                }
                //禁止地址
                if(count($prohibitArr)> 0)
                {
                    $pro_list = [];
                    $pro_arrs = [];
                    foreach ($prohibitArr as $prohibits)
                    {
                        $pro_arrs['bus_id'] = $data['bus_id'];
                        $pro_arrs['task_commod_id'] = $data['task_commod_id'];
                        $pro_arrs['value_service_id'] = $value_service_id;
                        $pro_arrs['pro_name'] = $prohibits['pro_name'];
                        $pro_arrs['pro_code'] = $prohibits['pro_code'];
                        $pro_arrs['city_name'] = $prohibits['city_name'];
                        $pro_arrs['city_code'] = $prohibits['city_code'];
                        $pro_arrs['create_time'] = time();
                        $pro_list[] = $pro_arrs;
                    }
                    //先删除禁止地区
                    $this->WValueServiceProhibitAccess->delProhibit($value_service_id);
                    $this->WValueServiceProhibitAccess->addProhibit($pro_list);

                }
                if($res_commod){
                    $sTaskArr = [
                        "task_num" => $task_commod['task_num'],
                        'price'=> $task_commod['price'],
                        'num' => $task_commod['num'],
                        'com_amount' => $task_commod['com_amount'],
                        'margin' => $task_commod['margin'],
                        'pay_task_amount' => $pay_task_amount,
                        'item_commisse' => $task_commod['item_commisse'],
                        'pay_task_commisse' => $pay_task_commisse,
                        'com_task_commisse' => $task_commod['com_task_commisse'],
                        'total_commisse' => number_format($task_commod['item_commisse'] * $task_commod['task_num'],2,".",""),
                        'service_amount'=> $value_service_amount,
                        'total_amount' => $total,
                        'img_praise_type' => $task_commod['img_praise_type'],
                        'img_prase_type_pepper' => $task_commod['img_prase_type_pepper'],
                        'task_img_pepper' => $task_commod['task_img_pepper'],
                        'task_commod_id' => $data['task_commod_id'],
                        'value_service_id' => $value_service_id,
                        'ava_deposit' => $buyUserAcount['ava_deposit'],
                        'ava_pepper' => $buyUserAcount['ava_pepper'],
                    ];
                    if($data['return_type']> 0)
                    {
                        $sTaskArr['return_type_pepper'] = $data['return_type_pepper'];
                    }
                    if($data['interval_time'] > 0)
                    {
                        $sTaskArr['return_type_pepper'] = $data['interval_pepper'];
                    }
                    if($data['pub_timing'] >0)
                    {
                        $sTaskArr['pub_timing_pepper'] = $data['pub_timing_pepper'];
                    }
                    if($data['end_timing'] >0)
                    {
                        $sTaskArr['end_timing_pepper'] = $data['end_timing_pepper'];
                    }
                    if($data['chat_type']> 0)
                    {
                        $sTaskArr['chat_pepper'] = $data['chat_pepper'];
                    }
                    if($data['exten_period'] >0)
                    {
                        $sTaskArr['extend_pepper'] = $data['extend_pepper'];
                    }
                    if($data['credit_card'] >0)
                    {
                        $sTaskArr['credit_card_pepper'] = $data['credit_card_pepper'];
                    }
                    if( $data['buy_sex'] >1)
                    {
                        $sTaskArr['sex_pepper'] = $data['sex_pepper'];
                    }
                    if($data['praise'] > 0)
                    {
                        $sTaskArr['praise_pepper'] = $data['praise_pepper'];
                    }
                    if($data['up_rank'] >0)
                    {
                        $sTaskArr['up_rank_pepper'] = $data['up_rank_pepper'];
                    }
                    if($is_prohibit == 1)
                    {
                        $sTaskArr['prohibit_pepper'] = $data['prohibit_pepper'];
                    }
                    if(!empty($data['buy_age']))
                    {
                        $sTaskArr['buy_age_pepper'] = $data['buy_age_pepper'];
                    }

                    if($data['reword_commise']>0)
                    {
                        $sTaskArr['reword_commise'] = $data['reword_commise'];
                    }
                    if($data['prio_audit']>0)
                    {
                        $sTaskArr['prio_audit_pepper'] = $data['prio_audit_pepper'];
                    }
                    if($data['reword_commise']>0)
                    {
                        $sTaskArr['reword_commise'] = $data['reword_commise'];
                    }
                    if($data['expre_service'] >0)
                    {
                        $sTaskArr['service_pepper'] = $data['service_pepper'];
                    }
                    if($data['free_shipping'] == 2)
                    {
                        $sTaskArr['freight_deposit'] = $freight_deposit;
                    }

                    $transaction->commit();
                    return Tool::returnJson($sTaskArr,200,"成功");
                }
                $transaction->rollBack();
                return Tool::returnJson([],419,"添加增值服务失败");
            }
            $transaction->rollBack();
            return Tool::returnJson([],420,"添加增值服务失败");
        }catch(Exception $e){
            $transaction->rollBack();
            return Tool::returnJson([],5000,"添加异常".$e->getMessage());
        }
    }
    //修改增值服务
    public function modifyValueService($data)
    {
        if(empty($data['value_service_id']))
        {
            return Tool::returnJson([],401,"增值服务id不能为空");
        }
        if(empty($data['return_type'])){
            return Tool::returnJson([],402,"返款方式不能为空");
        }
//        if(empty($data['weight'])){
//            return Tool::returnJson([],403,"请选择快递类型以及设置重量");
//        }
        if(empty($data['bus_id'])){
            return Tool::returnJson([],405,"商户id不能为空");
        }
        if(empty($data['task_commod_id'])){
            return Tool::returnJson([],406,"发布任务id不能为空");
        }
        if(empty($data['free_shipping']))
        {
            return Tool::returnJson([],407,"必须选择包邮或者不包邮");
        }
        if(!($data['free_shipping'] == 1 || $data['free_shipping'] == 2))
        {
            return Tool::returnJson([],408,"任务必须选择包邮或者不包邮");
        }

        $prohibitArr = [];
        $is_prohibit = 0;
        if(!empty($data['prohibit']))
        {
            $data['prohibit'] = array_filter($data['prohibit']);
            if(count($data['prohibit'])>3)
            {
                return Tool::returnJson([],408,"禁止地址步能超过三个");
            }
            $prohibit_pro_arr = array_column($data['prohibit'],"pro_code");
            $prohibit_pro_arr = array_filter($prohibit_pro_arr);
            $prohibit_city_arr = array_column($data['prohibit'],"city_code");
            $prohibit_city_arr = array_filter($prohibit_city_arr);
            if(!(empty($prohibit_pro_arr) || empty($prohibit_city_arr)))
            {
                $prohibitArr = $data['prohibit'];
                $is_prohibit = 1;
            }
        }

        //用户
        $buyUser = $this->RBuyUserAccess->getBuyUserInfo($data['bus_id']);
        if(empty($buyUser)){
            return Tool::returnJson([],410,'商家用户不存在');
        }
        $buyUserAcount = $this->RBuyUserAcountAccess->getBuyUserAccount($data['bus_id']);
//        if(empty($buyUserAcount))
//        {
//            return Tool::returnJson([],411,'没有账号信息，请充值');
//        }

        $task_commod = $this->RTaskCommodAccess->getTaskCommodById($data['task_commod_id']);
        if(empty($task_commod)){
            return Tool::returnJson([],412,"任务订单id不存在");
        }
//        if($task_commod['public_task_status'] != 4)
//        {
//            return Tool::returnJson([],413,"增值服务不能修改");
//        }
        //判断是否是图文任务
        if($task_commod['task_type'] == 2 && $task_commod['task_type'] == 0)
        {
            return Tool::returnJson([],413,"图文任务必须先上传图文");
        }
        if($task_commod['bus_id'] != $data['bus_id'])
        {
            return Tool::returnJson([],3000,"非本人任务不得添加增值服务");
        }


        //开始时间和结束时间
        if(!empty($data['pub_timing']) && !empty($data['end_timing']))
        {
            if(strtotime($data['end_timing']) - strtotime($data['pub_timing'])<7200)
            {
                return Tool::returnJson([],450,"任务开始时间与结束时间必须大于2小时");
            }
        }

        $praise_arr = [];
        if($data['praise'] == 1)
        {
            $data['praise_keys'] = [];
            $data['custom_praise'] = [];
        }else if($data['praise'] == 2)
        {
            if(!empty($data['praise_keys']) && $data['praise'] == 2)
            {
                $data['praise_keys'] = array_filter($data['praise_keys']);
                $data['praise_keys'] = implode( $data['praise_keys'],"|");
            }else
            {
                $data['praise_keys'] = [];
                $data['custom_praise'] = [];
            }

        }else if($data['praise'] == 3)
        {
            if(!empty($data['custom_praise']) && $data['praise'] == 3)
            {
                if(count($data['custom_praise'])>10)
                {
                    return Tool::returnJson([],415,"自定义好评关键字总数量不能超过10个");
                }
                if($data['praise'] == 3 && count($data['custom_praise'])>0)
                {
                    $data['custom_praise'] = array_filter($data['custom_praise']);
                    if($task_commod['task_num'] != count($data['custom_praise']))
                    {
                        return Tool::returnJson([],416,"自定义关键字数量和任务单数不匹配");
                    }
                    $praise_arr = $data['custom_praise'];
                }
            }else
            {
                $data['praise_keys'] = [];
                $data['custom_praise'] = [];
            }
        }


        $freight_deposit = 0;
        //是否包邮  包邮增加10元押金
        if($data['free_shipping'] == 2)
        {
            $freight_deposit = 10;
        }
        //判断增值服务是否以及添加
        $valueArr = $this->RValueServiceAccess->getValueServiceByCommodId($data['task_commod_id']);
        if(empty($valueArr)){
            return Tool::returnJson([],417,"任务增值服务未添加");
        }
        //判断开始实际是否是日期格式
        //判断开始实际是否是日期格式
        if(!empty($data['pub_timing']))
        {
            if(strtotime($data['pub_timing']))
            {
                $data['pub_timing'] = strtotime($data['pub_timing']);
            }
        }

        if(!empty($data['end_timing']))
        {
            if(strtotime($data['end_timing']))
            {
                $data['end_timing'] = strtotime($data['end_timing']);
            }
        }
        $avail_task_nu = 0;
        $surplus_task_num = 0;
        if(empty($data['interval_time']) && empty($data['pub_timing']))
        {
            $avail_task_nu = $task_commod['task_num'];
            $surplus_task_num = $task_commod['task_num'];
        }else
        {
            $avail_task_nu = 0;
            $surplus_task_num = 0;
        }

        $task_classify = 1;

        $data['return_type_pepper'] = $data['return_type'] >0 ? number_format($this->valueservice['return_type_pepper'][$data['return_type']] * $task_commod['price']* $task_commod['num'],2,'.','') : 0.00 ;
        //发布间隔
        $data['interval_pepper'] = $data['interval_time'] > 0 ? number_format($this->valueservice['interval_pepper'],2,'.','') : 0.00;
        //定时发布任务
        $data['pub_timing_pepper'] = $data['pub_timing'] > 0 ? number_format($this->valueservice['pub_timing_pepper'],2,'.','') : 0.00;
        //定时结束任务
        $data['end_timing_pepper']  = $data['end_timing'] >0 ? number_format($this->valueservice['end_timing_pepper'],2,'.','') : 0.00;
        //聊天服务类型
        $data['chat_pepper'] = $data['chat_type']> 1 ? number_format($this->valueservice['chat_type_pepper'][$data['chat_type']],2,'.','') : 0.00;
        //延长买手购物周期
        $data['extend_pepper'] = $data['exten_period'] >1 ? number_format($this->valueservice['exten_period_pepper'][$data['exten_period']],2,'.','')  : 0.00;
        //使用花呗信用卡花椒
        $data['credit_card_pepper'] = $data['credit_card'] >0 ? number_format($this->valueservice['credit_card'][$data['credit_card']],2,".","") : 0.00;
        //买号性别
        $data['sex_pepper'] = $data['buy_sex'] > 1 ? number_format($this->valueservice['buy_sex_pepper'][$data['buy_sex']],2,'.','') : 0.00 ;
        //好评优化
        $data['praise_pepper'] = $data['praise'] > 0  ? number_format($this->valueservice['praise_pepper'][$data['praise']],2,'.','') : 0.00;
        //任务提升排名
        $data['up_rank_pepper'] = $data['up_rank'] >0 ? number_format($this->valueservice['up_rank_pepper'][$data['up_rank']],2,'.','') : 0.00;
        //禁止地
        $data['prohibit_pepper'] = $is_prohibit == 1 ? number_format($this->valueservice['prohibit_pepper'] * count($data['prohibit']),2,'.','') : 0.00 ;
        //年龄区间
        $data['buy_age_pepper'] = !empty($data['buy_age'])? number_format($this->valueservice['buy_age_pepper'],2,'.','') : 0.00;
        //佣金加赏
        $data['reword_commise'] = $data['reword_commise']>0 ? number_format($data['reword_commise'],2,'.','') : 0.00;
        //优先审核
        $data['prio_audit_pepper'] = $data['prio_audit']>0 ? number_format($this->valueservice['prio_audit_pepper'][$data['prio_audit']],2,'.','') : 0.00;
        //快递服务花椒
        $data['service_pepper'] = $data['expre_service'] >0 ? number_format($this->valueservice['service_pepper'][$data['expre_service']],2,'.','') : 0.00;
        //修改任务金额
        $value_service_amount = 0.00;
        if($task_commod['task_type'] == 2)
        {
            $value_service_amount = number_format($data['return_type_pepper'] * $task_commod['task_num'] + $data['interval_pepper'] +  $data['pub_timing_pepper'] + $data['end_timing_pepper']
                + $data['chat_pepper']* $task_commod['task_num'] +  $data['extend_pepper'] * $task_commod['task_num']+ $data['credit_card_pepper']* $task_commod['task_num'] + $data['sex_pepper']*$task_commod['task_num']  + $data['buy_age_pepper'] +
                $data['praise_pepper'] * $task_commod['task_num'] + $data['up_rank_pepper'] + $data['prohibit_pepper'] + $data['reword_commise']* $task_commod['task_num'] + $data['prio_audit_pepper']
                +  $data['service_pepper'] * $task_commod['task_num'] + $task_commod['img_prase_type_pepper'] * $task_commod['task_num'] + $task_commod['task_img_pepper'] * $task_commod['task_num'],2,'.','');
        }else
        {
            $value_service_amount = number_format($data['return_type_pepper'] * $task_commod['task_num'] + $data['interval_pepper'] +  $data['pub_timing_pepper'] + $data['end_timing_pepper']
                + $data['chat_pepper']* $task_commod['task_num'] +  $data['extend_pepper'] * $task_commod['task_num']+ $data['credit_card_pepper']* $task_commod['task_num'] + $data['sex_pepper']* $task_commod['task_num'] + $data['buy_age_pepper'] +
                $data['praise_pepper'] * $task_commod['task_num'] + $data['up_rank_pepper'] + $data['prohibit_pepper'] + $data['reword_commise']* $task_commod['task_num'] + $data['prio_audit_pepper']
                +  $data['service_pepper'] * $task_commod['task_num'],2,'.','');
        }

        $pay_task_commisse = number_format( $value_service_amount + $task_commod['com_task_commisse'],2,".","");            //支付任务佣金
        //支付任务佣金
        $pay_task_amount = number_format($task_commod['price']*$task_commod['num']* $task_commod['task_num']*1.05 + $freight_deposit * $task_commod['task_num'],2,".","");   //支付任务总金额
        $item_task_amount = number_format($task_commod['price']* $task_commod['num']*(1+0.05) + $freight_deposit,2,".",""); //每单任务金额（包含任务保证金额）
        //总计金额
        $total = number_format($pay_task_commisse + $pay_task_amount,2,".","");

        //增加发布任务记录
        $transaction = Yii::$app->db->beginTransaction();
        try{
            $res = $this->WValueServiceAccess->modifyValueSevice($data);
            if($res){

                if($data['reword_commise'] > 0)
                {
                    $task_classify = 3;
                }
                if($data['credit_card'] ==1)
                {
                    $task_classify = 2;
                }
                $arr = [
                    'return_type' => $data['return_type'],
                    'freight_deposit' => $freight_deposit,
                    'avail_task_num' => $avail_task_nu,
                    'pay_task_commisse' => $pay_task_commisse,
                    'pay_task_amount' => $pay_task_amount,
                    'total_amount' => $total,
                    'service_amount' => $value_service_amount,
                    "public_task_status" =>4,
                    "item_task_amount" => $item_task_amount,
                    "task_classify" => $task_classify,
                    "surplus_task_num" => $surplus_task_num,
                    'id' => $task_commod['id'],
                ];
                $res_commod = $this->WTaskCommodAccess->modifyTaskCommod($arr);
                //自定义好评 非图文评论
                if(count($praise_arr) >0)
                {
                    $praise_list = [];
                    foreach ($praise_arr as $paraise)
                    {
                        $pra_arr = [];
                        $pra_arr['bus_id'] = $task_commod['bus_id'];
                        $pra_arr['task_commod_id'] = $data['task_commod_id'];
                        $pra_arr['value_service_id'] = $data['value_service_id'];
                        $pra_arr['word'] = $paraise;
                        $pra_arr['create_time'] = time();
                        $praise_list[] = $pra_arr;
                    }
                    $this->WPraiseKeywordsAccess->delPraisekeywords($data['value_service_id']);
                    $this->WPraiseKeywordsAccess->addPraiseKeywords($praise_list);
                }
                //禁止地址
                if(count($prohibitArr)> 0)
                {
                    $pro_list = [];
                    $pro_arrs = [];
                    foreach ($prohibitArr as $prohibits)
                    {
                        $pro_arrs['bus_id'] = $data['bus_id'];
                        $pro_arrs['task_commod_id'] = $data['task_commod_id'];
                        $pro_arrs['value_service_id'] = $data['value_service_id'];
                        $pro_arrs['pro_name'] = $prohibits['pro_name'];
                        $pro_arrs['pro_code'] = $prohibits['pro_code'];
                        $pro_arrs['city_name'] = $prohibits['city_name'];
                        $pro_arrs['city_code'] = $prohibits['city_code'];
                        $pro_arrs['create_time'] = time();
                        $pro_list[] = $pro_arrs;
                    }
                    //先删除禁止地区
                    $this->WValueServiceProhibitAccess->delProhibit($data['value_service_id']);
                     $this->WValueServiceProhibitAccess->addProhibit($pro_list);
                }
                if($res_commod){
                    $sTaskArr = [
                        "task_num" => $task_commod['task_num'],
                        'price'=> $task_commod['price'],
                        'num' => $task_commod['num'],
                        'com_amount' => $task_commod['com_amount'],
                        'margin' => $task_commod['margin'],
                        'pay_task_amount' => $pay_task_amount,
                        'item_commisse' => $task_commod['item_commisse'],
                        'pay_task_commisse' => $pay_task_commisse,
                        'com_task_commisse' => $task_commod['com_task_commisse'],
                        'service_amount'=> $value_service_amount,
                        'total_amount' => $total,
                        'img_praise_type' => $task_commod['img_praise_type'],
                        'img_prase_type_pepper' => $task_commod['img_prase_type_pepper'],
                        'task_img_pepper' => $task_commod['task_img_pepper'],
                        'task_commod_id' => $data['task_commod_id'],
                        'value_service_id' => $data['value_service_id'],
                        'ava_deposit' => $buyUserAcount['ava_deposit'],
                        'ava_pepper' => $buyUserAcount['ava_pepper'],
                    ];
                    if($data['return_type']> 0)
                    {
                        $sTaskArr['return_type_pepper'] = $data['return_type_pepper'];
                    }
                    if($data['interval_time'] > 0)
                    {
                        $sTaskArr['return_type_pepper'] = $data['interval_pepper'];
                    }
                    if($data['pub_timing'] >0)
                    {
                        $sTaskArr['pub_timing_pepper'] = $data['pub_timing_pepper'];
                    }
                    if($data['end_timing'] >0)
                    {
                        $sTaskArr['end_timing_pepper'] = $data['end_timing_pepper'];
                    }
                    if($data['chat_type']> 0)
                    {
                        $sTaskArr['chat_pepper'] = $data['chat_pepper'];
                    }
                    if($data['exten_period'] >0)
                    {
                        $sTaskArr['extend_pepper'] = $data['extend_pepper'];
                    }
                    if($data['credit_card'] >0)
                    {
                        $sTaskArr['credit_card_pepper'] = $data['credit_card_pepper'];
                    }
                    if( $data['buy_sex'] >1)
                    {
                        $sTaskArr['sex_pepper'] = $data['sex_pepper'];
                    }
                    if($data['praise'] > 0)
                    {
                        $sTaskArr['praise_pepper'] = $data['praise_pepper'];
                    }
                    if($data['up_rank'] >0)
                    {
                        $sTaskArr['up_rank_pepper'] = $data['up_rank_pepper'];
                    }
                    if($is_prohibit == 1)
                    {
                        $sTaskArr['prohibit_pepper'] = $data['prohibit_pepper'];
                    }
                    if(!empty($data['buy_age']))
                    {
                        $sTaskArr['buy_age_pepper'] = $data['buy_age_pepper'];
                    }
                    if($data['reword_commise']>0)
                    {
                        $sTaskArr['reword_commise'] = $data['reword_commise'];
                    }
                    if($data['prio_audit']>0)
                    {
                        $sTaskArr['prio_audit_pepper'] = $data['prio_audit_pepper'];
                    }
                    if($data['reword_commise']>0)
                    {
                        $sTaskArr['reword_commise'] = $data['reword_commise'];
                    }
                    if($data['expre_service'] >0)
                    {
                        $sTaskArr['service_pepper'] = $data['service_pepper'];
                    }
                    if($data['free_shipping'] == 2)
                    {
                        $sTaskArr['freight_deposit'] = $freight_deposit;
                    }

                    $transaction->commit();
                    return Tool::returnJson($sTaskArr,200,"成功");
                }
                $transaction->rollBack();
                return Tool::returnJson([],418,"修改增值服务失败");
            }
            $transaction->rollBack();
            return Tool::returnJson([],420,"修改增值服务失败");
        }catch(Exception $e){
            $transaction->rollBack();
            return Tool::returnJson([],5000,"修改异常".$e->getMessage());
        }
    }
    //获取增值服务信息
    public function getValueService($data)
    {
        if(empty($data['bus_id']))
        {
            return Tool::returnJson([],401,"商家用户id不能为空");
        }
        if(empty($data['value_service_id']))
        {
            return Tool::returnJson([],402,"增值服务id不能为空");
        }
        if(empty($data['safetyCode']))
        {
            return Tool::returnJson([],403,"安全码不能为空");
        }
        if(md5($data['bus_id'].$data['value_service_id']) != $data['safetyCode'])
        {
            return Tool::returnJson([],405,"安全码不能为空");
        }
        //用户
        $buyUser = $this->RBuyUserAccess->getBuyUserInfo($data['bus_id']);
        if(empty($buyUser)){
            return Tool::returnJson([],406,'买手用户不存在');
        }
        $value_service = $this->RValueServiceAccess->getValueServiceBySId($data['value_service_id']);
        if(empty($value_service))
        {
            return Tool::returnJson([],407,'增值服务记录不存在');
        }
        if($value_service['bus_id'] != $data['bus_id'])
        {
            return Tool::returnJson([],408,'非本商家充值记录');
        }
        $value_service['prohibit'] = $this->RValueServiceProhibitAccess->getValueServiceProhibit($data['value_service_id']);
        if($value_service['praise'] == 3)
        {
            $value_service['custom_praise'] = $this->RPraiseKeywordsAccess->getPraiseKeywords($value_service['id']);
        }
        return Tool::returnJson($value_service,200,"成功");
    }
    //获取增值服务花椒
    public function getTaskServicePapper($data)
    {
        if(empty($data['bus_id']))
        {
            return Tool::returnJson([],401,"商家用户id不能为空");
        }
        if(empty($data['task_commod_id']))
        {
            return Tool::returnJson([],402,"商家任务id不能为空");
        }
        if(empty($data['safetyCode']))
        {
            return Tool::returnJson([],403,"安全码不能为空");
        }
        if(md5($data['bus_id'].$data['task_commod_id']) != $data['safetyCode'])
        {
            return Tool::returnJson([],405,"安全码不正确");
        }
        //获取主任务信息
        $task_commod = $this->RTaskCommodAccess->getTaskCommodById($data['task_commod_id']);
        if(empty($task_commod))
        {
            return Tool::returnJson([],406,"主任务不存在");
        }
        if($data['bus_id'] != $task_commod['bus_id'])
        {
            return Tool::returnJson([],407,"非本用户任务");
        }
        $task_velue_service = [];

        //禁止地址修改
        $prohibitArr = [];
        $is_prohibit = 0;
        if(!empty($data['prohibit']))
        {
            $data['prohibit'] = array_filter($data['prohibit']);
            if(count($data['prohibit'])>3)
            {
                return Tool::returnJson([],408,"禁止地址步能超过三个");
            }
            $prohibit_pro_arr = array_column($data['prohibit'],"pro_code");
            $prohibit_pro_arr = array_filter($prohibit_pro_arr);
            $prohibit_city_arr = array_column($data['prohibit'],"city_code");
            $prohibit_city_arr = array_filter($prohibit_city_arr);
            if(!(empty($prohibit_pro_arr) || empty($prohibit_city_arr)))
            {
                $prohibitArr = $data['prohibit'];
                $is_prohibit = 1;
            }
        }


        if($task_commod['plat_type'] == 1 || $task_commod['plat_type'] == 2)
        {
            if($task_commod['task_type'] == 2)
            {
                $task_velue_service['img_praise_type'] = $task_commod['img_praise_type'];
                $task_velue_service['img_prase_type_pepper'] = $task_commod['img_prase_type_pepper'];
                $task_velue_service['task_img_pepper'] = $task_commod['task_img_pepper'];
            }
        }

        $service_amount = 0.00;

        $task_velue_service['return_type_pepper'] = $data['return_type'] >0 ? number_format($this->valueservice['return_type_pepper'][$data['return_type']]* $task_commod['price'] * $task_commod['num'],2,'.','') : 0.00 ;
        $service_amount  += $task_velue_service['return_type_pepper'] * $task_commod['task_num'];
        //发布间隔
        if($data['interval_time'] > 0)
        {
            $task_velue_service['interval_pepper'] = $data['interval_time'] > 0 ? number_format($this->valueservice['interval_pepper'],2,'.','') : 0.00;
            $service_amount += $task_velue_service['interval_pepper'];
        }
        //定时发布任务
        if($data['pub_timing'] > 0)
        {
            $task_velue_service['pub_timing_pepper'] = $data['pub_timing'] > 0 ? number_format($this->valueservice['pub_timing_pepper'],2,'.','') : 0.00;
            $service_amount  += $task_velue_service['pub_timing_pepper'];
        }
        //定时结束任务
        if($data['end_timing'] > 0)
        {
            $task_velue_service['end_timing_pepper'] = $data['end_timing'] > 0 ? number_format($this->valueservice['end_timing_pepper'],2,'.','') : 0.00;
            $service_amount  += $task_velue_service['end_timing_pepper'];
        }
        //聊天服务类型
        if($data['chat_type']> 1)
        {
            $task_velue_service['chat_pepper'] = $data['chat_type']> 1 ? number_format($this->valueservice['chat_type_pepper'][$data['chat_type']],2,'.','') : 0.00;
            $service_amount  += $task_velue_service['chat_pepper']*$task_commod['task_num'];
        }
        //延长买手购物周期
        if($data['exten_period'] >1)
        {
            //延长买手购物周期
            $task_velue_service['extend_pepper'] = $data['exten_period'] >1 ? number_format($this->valueservice['exten_period_pepper'][$data['exten_period']],2,'.','')  : 0.00;
            $service_amount  += $task_velue_service['extend_pepper']*$task_commod['task_num'];
        }
        //使用花呗信用卡花椒
        if($data['credit_card'] >0)
        {
            //使用花呗信用卡花椒
            $task_velue_service['credit_card_pepper'] = $data['credit_card'] >0 ? number_format($this->valueservice['credit_card'][$data['credit_card']],2,".","") : 0.00;
            $service_amount  += $task_velue_service['credit_card_pepper'] * $task_commod['task_num'];
        }
        //买号性别
        if($data['buy_sex'] > 1)
        {
            $task_velue_service['sex_pepper'] = $data['buy_sex'] > 1 ? number_format($this->valueservice['buy_sex_pepper'][$data['buy_sex']],2,'.','') : 0.00 ;
            $service_amount  += $task_velue_service['sex_pepper']* $task_commod['task_num'];
        }

        //任务提升排名
        if($data['up_rank'] >0)
        {
            $task_velue_service['up_rank_pepper'] = $data['up_rank'] >0 ? number_format($this->valueservice['up_rank_pepper'][$data['up_rank']],2,'.','') : 0.00;
            $service_amount  += $task_velue_service['up_rank_pepper'];
        }
        //年龄区间
        if(!empty($data['buy_age']))
        {
            $task_velue_service['buy_age_pepper'] = !empty($data['buy_age'])? number_format($this->valueservice['buy_age_pepper'],2,'.','') : 0.00;
            $service_amount  += $task_velue_service['buy_age_pepper'];
        }

        //禁止地
        if($is_prohibit>0)
        {
            $task_velue_service['prohibit_pepper'] =$is_prohibit == 1 ? number_format($this->valueservice['prohibit_pepper'],2,'.','') : 0.00 ;
            $service_amount  += $task_velue_service['prohibit_pepper']* count($data['prohibit']);
        }
        //佣金加赏
        if($data['reword_commise']>0)
        {
            $task_velue_service['reword_commise'] = $data['reword_commise']>0 ? number_format($data['reword_commise'],2,'.','') : 0.00;
            $service_amount  += $task_velue_service['reword_commise']* $task_commod['task_num'];
        }
        //优先审核
        if($data['prio_audit']>0)
        {
            $task_velue_service['prio_audit_pepper'] = $data['prio_audit']>0 ? number_format($this->valueservice['prio_audit_pepper'][$data['prio_audit']],2,'.','') : 0.00;
            $service_amount  += $task_velue_service['prio_audit_pepper'];
        }
        //快递服务花椒
        if($data['expre_service'] >0)
        {
            $task_velue_service['service_pepper'] = $data['expre_service'] >0 ? number_format($this->valueservice['service_pepper'][$data['expre_service']],2,'.','') : 0.00;
            $service_amount  += $task_velue_service['service_pepper'] * $task_commod['task_num'];
        }
        //判断是否是图文任务
        if($task_commod['task_type'] == 2)
        {
            $service_amount += $task_commod['img_prase_type_pepper'] * $task_commod['task_num'];
            $service_amount += $task_commod['task_img_pepper'] * $task_commod['task_num'];
        }else
        {
            //好评优化
            if($data['praise'] > 0 )
            {
                $task_velue_service['praise_pepper'] = $data['praise'] > 0  ? number_format($this->valueservice['praise_pepper'][$data['praise']],2,'.','') : 0.00;
                $service_amount  += $task_velue_service['praise_pepper'] * $task_commod['task_num'];
            }
        }
        $task_velue_service['freight_deposit'] = 0;
        if($data['free_shipping'] == 2)
        {
            $task_velue_service['freight_deposit'] = 10;
        }

        //支付任务 商家支付单件佣金
        $task_velue_service['price'] = $task_commod['price'];
        $task_velue_service['num'] = $task_commod['num'];
        $task_velue_service['task_num'] = $task_commod['task_num'];
        $task_velue_service['com_amount'] = $task_commod['com_amount'];                               //商品交易金额
        $task_velue_service['item_task_amount'] = number_format($task_commod['price']*$task_commod['num']*(1+0.05)+ $task_velue_service['freight_deposit'],2,".",""); //每单任务金额（包含任务保证金额）
        $task_velue_service['total_commisse'] = number_format($task_commod['item_commisse'] * $task_commod['task_num'],2,".","");                                                                  //基础费用合计
        $task_velue_service['margin'] = $task_commod['margin'];                                       //商品保证金
        $task_velue_service['pay_task_amount'] = number_format($task_commod['pay_task_amount'] + $task_velue_service['freight_deposit'] * $task_commod['task_num'],2,".","");                     //支付任务金额
        $task_velue_service['item_commisse'] = $task_commod['item_commisse'];                         //商家支付每单佣金
        $task_velue_service['buy_get_commisse'] = $task_commod['buy_get_commisse'];                  //买手获得佣金

        $task_velue_service['img_praise_type'] = $task_commod['img_praise_type'];
        $task_velue_service['img_prase_type_pepper'] = $task_commod['img_prase_type_pepper'];
        $task_velue_service['task_img_pepper'] = $task_commod['task_img_pepper'];

        $task_velue_service['com_task_commisse'] = $task_commod['com_task_commisse'];               //商品支付任务佣金
        $task_velue_service['pay_task_commisse'] = number_format($service_amount + $task_commod['item_commisse'] * $task_commod['task_num'],2,".","");               //支付任务佣金

        $task_velue_service['service_amount'] = number_format($service_amount,2,".","");                                    //增支服务总计
        $task_velue_service['total_amount'] = number_format(  $service_amount +  $task_velue_service['pay_task_amount'] + $task_velue_service['total_commisse'],2,".","");  //总计-合计


        return Tool::returnJson($task_velue_service,200,"成功");
    }

    //获取平台快递类型
    public function getExpress($data)
    {
        if(empty($data['plat_type']))
        {
            return Tool::returnJson([],401,"平台类型不能为空");
        }
        $all_express_arr = Yii::$app->params['plat_expre_type'];
        $arrs = [];
        if($data['plat_type'] ==1 || $data['plat_type'] == 2)
        {
            $arrs = [2,7,9];
        }else if($data['plat_type'] ==3)
        {
            $arrs = [4,5,7,8,10];
        }else if($data['plat_type'] ==4)
        {
            $arrs = [3,6,7,11];
        }
        $list = [];
        foreach ($all_express_arr as $express)
        {
            if(in_array($express['expre_type'],$arrs))
            {
                $list [] = $express;
            }
        }
        return Tool::returnJson($list,200,"成功");

    }
}